#include <iostream>
using namespace std;

const int kMaxN = 5e6 + 10;

int a[kMaxN], diff[kMaxN];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, p;

  cin >> n >> p;
  for (int i = 1; i <= n; i++) {  // 读入a数组
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {  // 构造diff数组
    diff[i] = a[i] - a[i - 1];
  }
  for (int i = 0; i < p; i++) {
    int x, y, z;

    cin >> x >> y >> z;
    diff[x] += z;  // 对两个diff数组中的两个端点操作
    diff[y + 1] -= z;
  }

  for (int i = 1; i <= n; i++) {  // 通过diff数组还原回a数组
    a[i] = diff[i] + a[i - 1];
  }

  int ans = a[1];
  for (int i = 2; i <= n; i++) {  // 找最小值
    ans = min(a[i], ans);
  }
  cout << ans << "\n";
  return 0;
}